// components/detailCmpt/index.js
// 成果详情页组件库

import "./index.less";
import {Image, Text, Video, View} from "@tarojs/components";
import {GLOBAL_IMAGE} from "../../constant/contant";
import {CommentItem} from "../CommentItem";
import {API_PATH, token} from "../../api/api";

export function AchVideo(props) {
    const {achDetail} = props;

    return (
        <View className={"achVideo"}>
            <Video
                id='video'
                className={"achVideo_main"}
                //src='https://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
                src={achDetail?.videoPath ? API_PATH + achDetail?.videoPath + "?token=" + token() : ''}
                //poster={GLOBAL_IMAGE.poster}
                initialTime={0}
                controls={true}
                autoplay={false}
                loop={false}
                muted={false}
            />
        </View>
    )
}

export function DetailInfo(props) {
    const {achDetail, talkNum} = props;

    return (
        <View className={"detailInfo"}>
            <View className={"info_title"}>
                <View className={"info_title_text"}>
                    <Text userSelect={true}>{achDetail?.proName}</Text>
                </View>
            </View>
            <View className={"interaction_row"}>
                <View className={"info_tag"}>
                    <Text>{achDetail?.itName}</Text>
                </View>
                <View className={"info_play"}>
                    <View className={"info_play_ico"}>
                        <Image src={GLOBAL_IMAGE.play}/>
                    </View>
                    <View className={"info_play_num"}>
                        <Text>{achDetail?.playTime}</Text>
                    </View>
                </View>
                <View className={"info_talk"}>
                    <View className={"info_talk_ico"}>
                        <Image src={GLOBAL_IMAGE.talk}/>
                    </View>
                    <View className={"info_talk_num"}>
                        <Text>{talkNum}</Text>
                    </View>
                </View>
            </View>
            <View className={"line_row"}>
                <Line/>
            </View>
            <View className={"company_row"}>
                <View className={"company_ico"}>
                    <Image src={GLOBAL_IMAGE.company}/>
                </View>
                <View className={"company_title"}>
                    <Text>所属单位</Text>
                </View>
            </View>
            <View className={"company_name"}>
                <Text userSelect={true}>{achDetail?.company}</Text>
            </View>
        </View>
    )
}

export function Article(props) {
    const {achDetail} = props;

    return (
        <View className={"article"}>
            <View className={"article_title"}>
                <Text>项目概述</Text>
            </View>
            <View className={"article_text_row"}>
                <View className={"article_text"}>
                    <Text userSelect={true}>{achDetail?.proIntro}</Text>
                </View>
            </View>
        </View>
    )
}

export function Line(props) {

    return (
         <View className={"line"}>

         </View>
    )
}

export function Comment(props) {
    const {
        talkNum, commentListOwn, commentListOther, commentRemove
    } = props;

    const getListOther = () => {
        const list = [];
        commentListOther.map((item, index) => {
            list.push(<CommentItem key={index} commentObj={item}/>);
            if (index % 2 === 1 && index !== commentListOther.length - 1) {
                list.push(<CommentLine key={`line-${index}`}/>);
            }
        });
        return list
    }

    return (
        <View className={"comment"}>
            <View className={"comment_title_row"}>
                <View className={"comment_title"}>
                    <Text>合作需求</Text>
                </View>
                <View className={"comment_num"}>
                    <Text>（{talkNum}）</Text>
                </View>
            </View>
            {
                commentListOwn?.length > 0 &&
                <View className={"comment_list_self"}>
                    <View className={"comment_list_self_title"}>
                        <Text>我的合作需求</Text>
                    </View>
                    {
                        commentListOwn.map((item, index) =>
                            <CommentItem isSelf={true}
                                         commentRemove={commentRemove}
                                         commentObj={item}
                                         key={index}
                            />
                        )
                    }
                </View>
            }
            <View className={"comment_list_other"}>
                {getListOther()}
                {/*<CommentItem/>*/}
                {/*<CommentLine/>*/}
                {/*<CommentItem/>*/}
            </View>
        </View>
    )
}

function CommentLine(props) {

    return (
        <View className={"commentLine"}>

        </View>
    )
}

export function OverTip(props) {

    return (
        <View className={"overTip"}>
            <Text>- 已经到底啦 -</Text>
        </View>
    )
}
